home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Internet software / framechat / framechat.cgi < prev    next >
Text File  |  1996-05-31  |  2KB  |  103 lines

  1. #!/usr/bin/perl
  2.  
  3. ############################################################
  4. # Set Variables
  5.  
  6. $chatlog = "/usr/local/etc/httpd/htdocs/framechat/chatlog.html";
  7. $cgiurl = "http://www.muzik.com/cgi-bin/framechat/framechat.cgi";
  8.  
  9. # Options:
  10.  
  11. $line_breaks = 0;
  12. $allow_html = 0;        # 1 = Yes; 0 = No
  13.  
  14.  
  15. # CONFIGURATION COMPLETE
  16. ############################################################
  17.  
  18.  
  19. # READ THE CHAT INFORMATION SENT BY CLIENT
  20.  
  21. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  22.  
  23. # UN WEBIFY TEXT
  24.  
  25. @pairs = split(/&/, $buffer);
  26. foreach $pair (@pairs) {
  27.    ($name, $value) = split(/=/, $pair);
  28.  
  29.    $value =~ tr/+/ /;
  30.    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  31.    $value =~ s/<!--(.|\n)*-->//g;
  32.  
  33.    if ($allow_html != 1) {
  34.       $value =~ s/<([^>]|\n)*>//g;
  35.    }
  36.  
  37.    $FORM{$name} = $value;
  38. }
  39.  
  40.  
  41.  
  42. # EDIT THE CHAT FILE
  43.  
  44. open (FILE,"$chatlog") || die "Can't Open $guestbookreal: $!\n";
  45. @LINES=<FILE>;
  46. close(FILE);
  47. $SIZE=@LINES;
  48.  
  49.  
  50.  
  51. # OPEN CHAT LOG TO ADD NEW TEXT
  52.  
  53. open (CHAT,">$chatlog") || die "Can't Open $guestbookreal: $!\n";
  54.  
  55. for ($i=0;$i<=25;$i++) {
  56.    $_=$LINES[$i];
  57.  
  58.    if (/<!--begin-->/) { 
  59. print CHAT "<!--begin-->\n";
  60.       print CHAT "<B>$FORM{'realname'}:</B>   $FORM{'comments'}<br>\n";
  61.  
  62. }
  63.  
  64.    else {
  65.       print CHAT $_;
  66.    }
  67.  
  68. }
  69.  
  70. close (CHAT);
  71.  
  72.  
  73. ############################################################
  74.  
  75.    &no_redirection;
  76.  
  77. ############################################################
  78.  
  79. # SEND CHAT TEXT WINDOW BACK TO CLIENT
  80. sub no_redirection {
  81.  
  82. # RETURN THE CHAT INTERFACE TO THE CLIENT
  83.  
  84. print "Content-Type: text/html\n\n";
  85. print "<html><head><title>Thank You</title>\n";
  86. print "<BODY BGCOLOR=\"#440099\" TEXT=\"#ffffff\" LINK=\"#00ffFF\" VLINK=\"#00ffff\" ALINK=\"#FF0000\"></head>\n";
  87.  
  88. print "<body><form method=POST action=\"http://www.yourserver.com/cgi-bin/framechat/framechat.cgi\">\n";
  89. print "<input type=hidden name=\"realname\" value=\"$FORM{'realname'}\">\n";
  90.  
  91. print "<TABLE BORDER=0 CELLPADDING=0 WIDTH=100%>";
  92. print "<TD ALIGN=center>";
  93. print "<textarea name=comments value=\"$FORM{'comments'}\"COLS=40 ROWS=4></textarea><p>\n";
  94. print "<TD ALIGN=center>";
  95. print "<input type=submit value=\"SPEAK\"><HR><input type=reset value=\"CLEAR\">\n";
  96. print "</form>\n";
  97. print "</table>";
  98. print "</body></html>\n";
  99.  
  100.    exit;
  101. }
  102.  
  103.